import cn.yunhe.dao.ILibDao;
import cn.yunhe.dao.IPointDao;
import cn.yunhe.dao.ITypeDao;
import cn.yunhe.entity.*;
import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;


/**
 * Created by 王雪丹 on 2018/5/23.
 */
public class demo {
    @Test
    public void test1(){
        ApplicationContext applicationContext = new ClassPathXmlApplicationContext("spring/spring-mybatis.xml");
        ILibDao libDao = (ILibDao) applicationContext.getBean("libDao");

        /*Lib lib = new Lib();
        Teacher t = new Teacher();
        t.setTeacher_id(1);
        lib.setLib_name("文学题库");
        lib.setLib_desc("文学知识类型");
        lib.setTeacher(t);
        libDao.addLib(lib);*/

       /* Teacher t = new Teacher();
        t.setTeacher_id(1);
        Lib lib1 = libDao.getOne(1);
        lib1.setLib_name("计算机题库");
        lib1.setTeacher(t);
        libDao.updateLib(lib1);*/

        //libDao.delLib(4);

        ITypeDao typeDao = (ITypeDao) applicationContext.getBean("typeDao");
        Type type = new Type();
         type.setType_name("多选题");
        //typeDao.addType(type);
        //type.setType_id(3);
        //typeDao.delType(type);

        IPointDao pointDao = (IPointDao) applicationContext.getBean("pointDao");
        Course course = new Course();
        course.setCourse_id(1);
        Lib lib = new Lib();
        lib.setLib_id(1);
        Teacher teacher = new Teacher();
        teacher.setTeacher_id(1);
        Point point = new Point();
        point.setPoint_id(2);
        //point.setCourse(course);
        //point.setPoint_name("java高级");
        //point.setLib(lib);
        //point.setTeacher(teacher);
        Point p = pointDao.getById(point);
        p.setPoint_name("java高级");
        System.out.println(p.getPoint_id()+","+p.getPoint_name()+p.getCourse().getCourse_name()+","+p.getTeacher().getTeacher_name());
        //pointDao.addPoint(point);
        pointDao.updatePoint(p);




    }
}
